﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace RouteMaster
{
    public static class ReportBuilder
    {
        public static void Report(IEnumerable<RouteLeg> legs)
        {
            string sz = ReportToString(legs);
            Debug.Write(sz);
        }

        private static string ReportToString(IEnumerable<RouteLeg> legs)
        {
            var sb = new StringBuilder();
            var temp = new List<RouteLeg>(legs);
            temp.Reverse();

            foreach (var l in temp)
            {
                if (l._busRoute == null)
                {
                    sb.Append("Leave at " + l._busStopStart.PlaceName + ".\r\n");
                }
                else
                {
                    sb.Append("At " + l._busStopStart.PlaceName + " board the " + l._busRoute + " bus.\r\n");
                }

            }
            return sb.ToString();
        }

        public static Dictionary<string, string> ReportToDictionary(RouteItinerary legs)
        {
            return legs.ReportToDictionary();
        }
    }
}
